In.ready('layer','validform',function(){
    ajaxSubForm('#regForm');
    $('#btnGetCode').click(function () {
        var o=$(this);
        if(o.hasClass("disabled")){
            return;
        }
        var mobile=$("input[name='mobile']").val();
        var vcode=$("input[name='vcode']").val();
        var $do=$("input[name='do']").val();
        if(mobile==""){
            $('#validError').addClass('Validform_wrong').text('请输入手机号！');
            return false;
        }
        if(vcode==""){
            $('#validError').addClass('Validform_wrong').text('请输入图形验证码！');
            return false;
        }
        var sendUrl = o.data('url');
        getAjax(sendUrl,{mobile:mobile,vcode:vcode,do:$do},function (res) {
            if(res.code==1){
                $('#validError').removeClass('Validform_wrong').text('');
                var countdown=179;
                var iCount = setInterval (function () {
                    o.text(countdown-- +"s后重试");
                    o.attr("disabled",true);
                    if(countdown==0){
                        o.removeAttr("disabled");
                        o.text("获取验证码");
                        clearInterval(iCount);//清除倒计时
                        countdown=180;//设置倒计时时间
                        $('.captcha').click();
                    };
                }, 1000);
            }else{
                $('#validError').text(res.msg);
                $('.captcha').click();
            }
        });
    });
    $('.captcha').click(function () {
        var src='/captcha.html?rnd=' + Math.random();
        $(this).attr('src',src);
    });
})